import {
  TableBaseColumn,
  TableColumnGroup,
  TableSelectionColumn,
  TableExpandColumn,
  InternalRowData
} from 'naive-ui/es/data-table/src/interface'
import { DictOptions } from './common'

export type CommonProColumnInfo = {
  type?:
    | 'selection'
    | 'expand'
    | 'dict'
    | 'tag'
    | 'link'
    | 'switch'
    | 'date'
    | 'index'
    | 'operation'
  props?: {
    [index: string]: unknown
  }
  key?: string
  title?: string
  dictOptions?: DictOptions[]
  valueCode?: string
  labelCode?: string
  dictCode?: number | string
  format?: string
  checkedText?: string
  uncheckedText?: string
  visiable?: boolean
  displayValue?: (row?: any, index?: number) => any
  click?: (row?: any, index?: number) => any
}

type ProTableBaseColumn<T> = TableBaseColumn<T> & CommonProColumnInfo
type ProTableColumnGroup<T> = TableColumnGroup<T> & CommonProColumnInfo
type ProTableSelectionColumn<T> = Omit<TableSelectionColumn<T>, 'type'> &
  CommonProColumnInfo
type ProTableExpandColumn<T> = Omit<TableExpandColumn<T>, 'type'> &
  CommonProColumnInfo

export type ProTableColumn<T = InternalRowData> =
  | ProTableBaseColumn<T>
  | ProTableColumnGroup<T>
  | ProTableSelectionColumn<T>
  | ProTableExpandColumn<T>

export type ProTableColumns = ProTableColumn[]
